<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *概况
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$basic=$this->plugin_setting('basic');
	$return['htmls']=array();
	//站点月/总数据对比
	//挪车卡
	$month_start=strtotime(date('Ym').'01');
	$card['month']=pdo_count('jy_move_agentcar_cards',array('uniacid'=>$_SESSION['uniacid'],'createtime >'=>$month_start));
	$card['all']=pdo_count('jy_move_agentcar_cards',array('uniacid'=>$_SESSION['uniacid']));
	//会员
	$member['month']=pdo_count('jy_move_agentcar_member',array('uniacid'=>$_SESSION['uniacid'],'createtime >'=>$month_start));
	$member['all']=pdo_count('jy_move_agentcar_member',array('uniacid'=>$_SESSION['uniacid']));
	//领卡
	$member_card['month']=pdo_count('jy_move_agentcar_cards',array('uniacid'=>$_SESSION['uniacid'],'mid >'=>0,'createtime >'=>$month_start));
	$member_card['all']=pdo_count('jy_move_agentcar_cards',array('uniacid'=>$_SESSION['uniacid'],'mid >'=>0));
	//扫描次数
	$scan_log['month']=pdo_count('jy_move_agentcar_scan_log',array('uniacid'=>$_SESSION['uniacid'],'createtime >'=>$month_start));
	$scan_log['all']=pdo_count('jy_move_agentcar_scan_log',array('uniacid'=>$_SESSION['uniacid']));
	$return['htmls'][]=array('type'=>'data','one_num'=>3,'title'=>'站点本月/总数据指标','datas'=>array(
		array('title'=>'新增挪车卡','num'=>2,'data'=>array($card['month'],$card['all'])),
		array('title'=>'新增会员','num'=>2,'data'=>array($member['month'],$member['all'])),
		array('title'=>'领卡次数','num'=>2,'data'=>array($member_card['month'],$member_card['all'])),
		array('title'=>'扫描次数','num'=>2,'data'=>array($scan_log['month'],$scan_log['all'])),
	));
	//近三十天挪车卡扫描走势
	$day=date('Ymd',strtotime('-30 days'));
	
	$scan_logs=pdo_fetchall('select `date`,count(*) from '.tablename('jy_move_agentcar_scan_log').' where uniacid='.$_SESSION['uniacid'].' and date >'.$day.' group by date');
	$scan_logs_1=array();
	if($scan_logs){
		foreach($scan_logs as $log){
			$scan_logs_1[$log['date']]=$log['count(*)'];
		}
	}
	
	$scan_log_data=array();
	$dates=array();
	for($i=0;$i<30;$i++){
		$temp_date=date('Ymd',strtotime('-'.(29-$i).' days'));
		$dates[]=$temp_date;
		$scan_log_data[]=$scan_logs_1[$temp_date]?$scan_logs_1[$temp_date]:0;
	}
	$markPoint=array('data'=>array(
		array('type'=>'min','name'=>'最小值'),
		array('type'=>'max','name'=>'最大值')
	));
	$options=array(
		'title'=>array('text'=>'近三十天挪车卡扫描走势'),
		'tooltip'=>array('trigger'=>'axis'),
		'legend'=>array('data'=>array('扫描记录'),'textStyle'=>array('color'=>'auto')),
		//'grid'=>array('x'=>40,'x2'=>40,'y2'=>24),
		//'calculable'=>true,
		'xAxis'=>array(
			array('type'=>'category','boundaryGap'=>false,'data'=>$dates),
		),
		'yAxis'=>array(
			
			array('name'=>'扫描记录','type'=>'value'),
		),
		'series'=>array(
			array('name'=>'扫描记录','type'=>'line','data'=>$scan_log_data),
		),
	);
	$return['htmls'][]=array('type'=>'echarts','name'=>'gs','options'=>$options);
	//近一月会员增长趋势图
	//
	set_html('title','挪车概况');
	$plugin_menu=$this->menu();
	set_html('framess',$plugin_menu);
	exi($return);
}